Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Conversation

@nablaone
Copy link
Member

@nablaone nablaone commented Jun 4, 2025

Fixes not protected concurrent map access.

fatal error: concurrent map read and map write

goroutine 193 [running]:
internal/runtime/maps.fatal({0xa2c93c?, 0x0?})
        /usr/local/go/src/runtime/panic.go:1058 +0x20
github.com/QuesmaOrg/quesma/platform/stats.(*Statistics).Process(0x1279838?, 0x9f?, {0x400e74199f?, 0x22?}, 0x1d?, {0xa09a4e?, 0x2b?})
        /platform/stats/ingest_statistics.go:127 +0x60
github.com/QuesmaOrg/quesma/platform/functionality/bulk.sendToClickhouse({0xc02f78, 0x4015dda210}, 0x0?, {0xf920c5f2d4b8, 0x40001ea408}, 0x1, 0x4000323400)
        /platform/functionality/bulk/bulk.go:274 +0x18c

@cloudflare-workers-and-pages
Copy link

Deploying quesma with  Cloudflare Pages  Cloudflare Pages

Latest commit: 71bf37e
Status: ✅  Deploy successful!
Preview URL: https://2403c996.quesma.pages.dev
Branch Preview URL: https://ingest-stats-panic.quesma.pages.dev

View logs

@nablaone
Copy link
Member Author

nablaone commented Jun 4, 2025

/run-it

@nablaone nablaone marked this pull request as ready for review June 4, 2025 11:36
@nablaone nablaone requested a review from a team as a code owner June 4, 2025 11:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR aims to fix a panic caused by concurrent map access by adjusting the mutex lock placement.

  • Removed redundant lock from the internal process function.
  • Added explicit locking in the Process and UpdateNonSchemaValues functions to protect shared map access.
Comments suppressed due to low confidence (1)

platform/stats/ingest_statistics.go:123

  • Ensure that the updated locking strategy is consistently applied; verify that the process function is only invoked via the wrapper methods where the lock is acquired to prevent unintended concurrent access from elsewhere.
defer mu.Unlock()


func (s *Statistics) Process(ingestStatsEnabled bool, index string, jsonData types.JSON, nestedSeparator string) {

mu.Lock()
Copy link

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider narrowing the scope of the mutex lock to only cover the critical map access operations to reduce potential contention if the process function performs heavy processing.

Copilot uses AI. Check for mistakes.
@nablaone nablaone added this pull request to the merge queue Jun 4, 2025
Merged via the queue into main with commit 4e03bae Jun 4, 2025
7 checks passed
@nablaone nablaone deleted the ingest-stats-panic branch June 4, 2025 12:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants